package cn.dkk.behavior_design.state.before;

/**
 * @author dkk
 * @date 2022/7/25
 * @desc
 */
public class Left implements ILeft {

    private int state;

    @Override
    public void setState(int i) {
        this.state=i;
    }

    @Override
    public void open() {
        switch (state){
            case OPENING_STATE:
                break;
            case CLOSING_STATE:
                System.out.println("电梯门开了");
                setState(OPENING_STATE);
                break;
            case RUNNING_STATE:
                break;
            case STOPPING_STATE:
                System.out.println("电梯门开了");
                setState(OPENING_STATE);
                break;
        }
    }

    @Override
    public void close() {
        switch (state){
            case OPENING_STATE:
                System.out.println("电梯门关了");
                setState(CLOSING_STATE);
                break;
            case CLOSING_STATE:
                break;
            case RUNNING_STATE:
                break;
            case STOPPING_STATE:
                System.out.println("电梯门关了");
                setState(CLOSING_STATE);
                break;
        }
    }

    @Override
    public void run() {
        switch (state){
            case OPENING_STATE:
                break;
            case CLOSING_STATE:
                System.out.println("电梯运行了");
                setState(RUNNING_STATE);
                break;
            case RUNNING_STATE:
                break;
            case STOPPING_STATE:
                System.out.println("电梯运行了");
                setState(RUNNING_STATE);
                break;
        }
    }

    @Override
    public void stop() {
        switch (state){
            case OPENING_STATE:
                break;
            case CLOSING_STATE:
                System.out.println("电梯停止了");
                setState(STOPPING_STATE);
                break;
            case RUNNING_STATE:
                System.out.println("电梯停止了");
                setState(STOPPING_STATE);
                break;
            case STOPPING_STATE:
                break;
        }
    }
}
